<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
</head>
<body>
<div class="layui-form timo-compile">
    <form th:action="@{/mains/bill/save}">
        <input type="hidden" name="id" th:value="${billId}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">请选择</label>
            <div class="layui-input-inline">
                <input type="radio" name="states" class="selfOn" value="2" title="通过" checked><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>通过</div></div>
                <input type="radio" name="states" class="selfOn" value="1" title="不通过" ><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>不通过</div></div>
            </div>
        </div>
        <div id="yesDisplay">
            <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label required">医疗机构</label>-->
                <!--<div class="layui-input-inline">-->
                    <!--<input class="layui-input select-tree" th:attr="data-url=@{/system/dept/list}, data-value=${user?.dept?.id}"-->
                           <!--type="text" name="dept"  placeholder="请选择所在部门" th:value="${user?.dept?.title}">-->
                <!--</div>-->
            <!--</div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">医疗机构</label>
                <div class="layui-input-inline">
                    <select name="kinds" lay-verify="required" id="companyId" lay-filter="companyId">
                        <option th:each="car:${company}" th:value="${car.id}" th:text="${car.name}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">服务项目</label>
                <div class="layui-input-inline">
                    <select name="prodId" lay-verify="required" id="prodId">

                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">凭证单号:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="oldCode"  placeholder="请输入凭证单号">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">消费金额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="amount" placeholder="请输入凭证消费金额">
                </div>
            </div>
        </div>
        <div style="display: none" id="noDisplay">
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label required">原因:</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" name="remark"></textarea>
                </div>
            </div>
        </div>
        <div class="layui-form-item timo-finally">
            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: script"></script>
<script type="text/javascript" th:src="@{/js/plugins/jquery-3.3.1.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
   layui.use([ 'jquery', 'form' ],function () {
       var form = layui.form, layer = layui.layer, laydate = layui.laydate;
       $("form").on("click",function(){
           var kinds = $('input[name="states"]:checked').val();
           if(kinds==2){
               $("#noDisplay").hide();
               $("#yesDisplay").show()
           } else {
               $("#noDisplay").show();
               $("#yesDisplay").hide();
           }
       });

       form.on('select(companyId)',function(data){
           var companyId = data.value;
           var op = "";
           $("#prodId").empty();
           $.ajax({
               url:"/mains/company/prodList?comId="+companyId,
               success:function(end){
                   for (var i = 0; i < end.length; i++) {
                       var prodIdId = end[i].id;
                       var prodName = end[i].prodName;
                       op += '<option value="'+prodIdId+'">'+prodName+'</option>'
                   }
                   $("#prodId").append(op);
                   form.render();
               }
           });


       });
   });


</script>
</body>
</html>